﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="Scripts/jquery-2.1.4.min.js"></script>



    <script>
        function colorChg(name) {
            return "<font color='red'>" + name + "</font>"
        }

        function check(str) {
            var gyear = str;
            return "row['" + str + "']";

        }
        function test1() {
            var s = prompt("请输入在查询的字符", "人");
            var reg = new RegExp("(" + s + ")", "g");
            var str = "中华人民共和国,中华人民共和国";
            var newstr = str.replace(reg, colorChg);
            document.write(newstr);
        }

        function test2() {
            //var str = "他今年[22]岁,她今年[20]岁,他的爸45岁,她的爸爸[44]岁,一共4个人";

            ////var reg = /{^\{}*\{(.*)\}{^\}}*/;
            //var reg = /[^\[]*\[(.*)\][^\]]*/;
            ////var reg = /{{^\}}*/;

            ////var reg = new RegExp("{{(\\d+)}}", "g");
            //var newstr = str.replace(reg, check);
            //alert(str);
            //alert(newstr);

            var str = "内容内容内AAAABBB容CCEE内容{em567}内容{abc}内容"

           var reg = new RegExp('\\{(.+?)\\}', "g");

            //reg = /\[em(.+?)\]/g 

           var ss = str.replace(reg, "$1.jpg");

           alert(ss);
           // //var reg = /{^\{}*\{(.*)\}{^\}}*/;
           //var reg = new RegExp("\\((.| )+?\\)", "igm");
           // var str = "1111(122)"; console.log(str.replace(reg, '$1'));
           //var str2 = "23[adf[223]]"; console.log(str2.replace(reg, '$1'));
        }
    </script>
</head>
<body>
    <button type="button" onclick="test1()">test1</button>

    <button type="button" onclick="test2()">test2</button>

</body>
</html>
